<template>
    <div class="app-container" style="border: 1px solid #eee">
        <!-- 列表 -->
        <qa-table
            :source="tableData"
            :columns="columns"
            :selection="false"
            :loading="loading"
            @sortChange="sortChange"
            @statusChange="statusChange"
            @selectionChange="selectionChange"
            id="quickadmin"
        >
        </qa-table>
        <!-- 分页 -->
        <pagination :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="initIndex"/>
    </div>
</template>

<script>
import {curdMixin} from '@/mixins/curdMixin'

export default {
    name: 'Curd',
    mixins: [curdMixin],
    props: {
        userId: {
            type: [String, Number],
            default: ''
        },
        targetUserId: {
            type: [String, Number],
            default: ''
        }
    },
    data() {
        return {
            // table结构
            columns: [
                {
                    visible: true,
                    label: '发送人',
                    prop: 'user_id',
                    component: 'QuickAdminText',
                    formatter: (prop, row) => {
                        return row.user_id === this.userId ? "需求方" : "合作方"
                    }
                },
                {
                    visible: true,
                    label: '消息内容',
                    prop: 'content',
                    component: 'QuickAdminText',
                    formatter: (prop, row) => {
                        if (row.type === 'image')
                            return `<img src="${row.content}" height="36" />`
                        return row.content
                    }
                },
                {
                    visible: true,
                    label: '发送时间',
                    prop: 'create_time',
                }
            ],
            // 接口地址
            api: {
                index: `/admin/pz.task_dispute/chatList`,
            },
            editFormParams: {},
            // 搜索表单是否展开
            searchExpand: false,
            // 查询参数
            queryParams: {},
            tableIsJoinLoad: false
        }
    },
    created() {
        this.api.index = `/admin/pz.task_dispute/chatList?user_id=${this.userId}&target_user_id=${this.targetUserId}`
        this.initIndex()
    }
}
</script>
